const request = (url, option = {}) => {
  if (option.body) {
    option.body = JSON.stringify(option.body);
  }
  const newOption = {
    headers: {
      'Content-Type': 'application/json',
      Authorization: localStorage.getItem('token'),
    },
    ...option,
  };
  return fetch(url, newOption)
    .then((res) => res.json())
    .catch((err) => alert(err));
};
export default request;
